package com.xxgc.vfc.modules.consumer.university.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.xxgc.vfc.api.dto.SchoolsDTO;
import com.xxgc.vfc.api.result.Result;
import com.xxgc.vfc.api.service.ISchoolService;
import com.xxgc.vfc.api.vo.SchoolsVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

/**
 *
 * @Author: Sjy
 * @Date :2023/10/20 - 10 - 20 - 16:39
 * 院校接口
 */
//登录后才能访问
@SaCheckLogin
@Slf4j
@Api(tags = "大学")
@RestController
@RequestMapping("/university")
public class UniversityController {
    public static Integer id = 0;

    @DubboReference(
        loadbalance = "roundrobin",check = false
    )
    private ISchoolService iSchoolService;


    @ApiOperation(value = "获取学校名称")
    @GetMapping("/getUniversityName")
    public Result getUniversityName(){
        id ++;
        System.out.println("请求"+id);
        return Result.ok().msg("成都信息工程大学");
    }

    @ApiOperation(value = "添加学校")
    @PostMapping("/addSchool")
    public Result addSchool(@RequestBody SchoolsVO schoolsVO){
        iSchoolService.addSchool(schoolsVO);
        return Result.ok();
    }

    @ApiOperation(value = "通过id查询学校")
    @GetMapping("/getSchoolById")
    public Result<SchoolsDTO> getSchoolById(Integer id){
        log.info("id:"+id);
        log.info("2222222222222222222222222222");
        SchoolsDTO schoolsDTO = iSchoolService.getSchoolById(id);
        return Result.ok(schoolsDTO);
    }



}
